<template>
	<view class="user">
		<view class="headtop">
			<image src="../../static/images/wode_newbj.png" class="bj"></image>
			<view class="headtitile">我的</view>
			<view class="xinxi">
				<view class="shang clearfix">
					<view class="left fl">
						<image src="../../static/images/avatar.png" class="logo"></image>
					</view>
					<view class="right fl">
						<view class="username">{{userData.username}}</view>
						<view class="name">账号：{{userData.mobile}}</view>
					</view>
				</view>
				<view class="xia clearfix">
					<view class="li fl">
						<view class="shuzi">{{countData.sjcount}}</view>
						<view class="desc">已开发商家</view>
					</view>
					<view class="li fl">
						<view class="shuzi">{{countData.kfkhcount}}</view>
						<view class="desc">已开发客户</view>
					</view>
					<view class="li fl">
						<view class="shuzi">{{countData.tkcount}}</view>
						<view class="desc">已拓客次数</view>
					</view>
					<view class="li fl" @click="topage('/pages/user/second/team')">
						<view class="shuzi">{{countData.teamcount}}</view>
						<view class="desc">AI团队</view>
					</view>
				</view>
			</view>
		</view>
		<view class="mydownlasttop">
			<view class="mydownlast">
				<view class="list clearfix" @click="topage('/pages/user/second/grab_record')">
					<view class="left fl">
						<image src="../../static/images/jiaoxue_tb.png"></image>
					</view>
					<view class="center fl">AI获取记录</view>
					<view class="right fr">
						<image src="../../static/images/right.png"></image>
					</view>
				</view>
			</view>
			<view class="mydownlastxia">
				<view class="list clearfix" @click="call">
					<view class="left fl">
						<image src="../../static/images/kefu_tb.png"></image>
					</view>
					<view class="center fl">在线客服</view>
					<view class="right fr">
						<image src="../../static/images/right.png"></image>
					</view>
				</view>
				<view class="list clearfix" @click="topage('/pages/user/second/feedback')">
					<view class="left fl">
						<image src="../../static/images/fankui_tb.png"></image>
					</view>
					<view class="center fl">用户反馈</view>
					<view class="right fr">
						<image src="../../static/images/right.png"></image>
					</view>
				</view>
				<view class="list clearfix" @click="topage('/pages/user/second/about')">
					<view class="left fl">
						<image src="../../static/images/about_tb.png"></image>
					</view>
					<view class="center fl">关于我们</view>
					<view class="right fr">
						<image src="../../static/images/right.png"></image>
					</view>
				</view>
				<view class="list clearfix" @click="topage('/pages/user/second/yinsi')">
					<view class="left fl">
						<image src="../../static/images/yinsi_tb.png"></image>
					</view>
					<view class="center fl">隐私协议</view>
					<view class="right fr">
						<image src="../../static/images/right.png"></image>
					</view>
				</view>
				<view class="list clearfix" v-if="userData.identity == 2" @click="qiehuan">
					<view class="left fl">
						<image src="../../static/images/exit_tb.png"></image>
					</view>
					<view class="center fl">切换为合伙人</view>
					<view class="right fr">
						<image src="../../static/images/right.png"></image>
					</view>
				</view>
			</view>
			<view class="mydownlast">
				<view class="list clearfix" @click="tuichu">
					<view class="left fl">
						<image src="../../static/images/exit_tb.png"></image>
					</view>
					<view class="center fl">退出登录</view>
					<view class="right fr">
						<image src="../../static/images/right.png"></image>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		request
	} from '@/api/request';

	export default {
		data() {
			return {
				userData: {
					mobile: '',
					role: 1,
				},
				app_tell: '',
				countData: {
					teamcount: 0,
					sjcount: 0,
					kfkhcount: 0,
					tkcount: 0,
				},
			}
		},
		created() {
			// 用户基本信息
			request({
				url: '/api/user/profile',
				method: 'GET',
				data: {},
				header: {
					'xx-token': uni.getStorageSync('token')
				}
			}).then((response) => {
				this.userData = response.data;
			}).catch((error) => {});

			// 数据统计
			request({
				url: '/api/user/counttj',
				method: 'GET',
				data: {},
				header: {
					'xx-token': uni.getStorageSync('token')
				}
			}).then((response) => {
				this.countData = response.data.list;
			}).catch((error) => {});

			// 关于我们-客服电话
			request({
				url: '/api/user/about',
				method: 'GET',
				data: {},
				header: {
					'xx-token': uni.getStorageSync('token')
				}
			}).then((response) => {
				let option_value = JSON.parse(response.data.list.option_value);

				this.app_tell = option_value.app_tell;
			}).catch((error) => {});
		},
		methods: {
			tuichu() {
				uni.removeStorageSync('token');

				uni.showToast({
					title: '退出成功，请重新登录！',
					icon: 'none'
				}).then(() => {
					uni.reLaunch({
						url: '/pages/user/second/login'
					});
				});
			},
			qiehuan(){
				uni.reLaunch({
					url: '/pagesSale/index/index'
				})
			},
			call() {
				let tell = this.app_tell;

				//#ifdef MP-WEIXIN
				uni.makePhoneCall({
					phoneNumber: tell
				});
				//#endif
				//#ifdef APP-PLUS
				plus.device.dial(tell, true);
				//#endif
			},
			topage(url) {
				uni.navigateTo({
					url
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	.user {
		width: 100%;
		margin: 0 auto;

		.headtop {
			width: 100%;
			margin: 0 auto;
			position: relative;
			height: 523rpx;
			z-index: 200;
			background: #191D26;
			border-radius: 30rpx 30rpx 0rpx 0rpx;

			.bj {
				width: 100%;
				height: 503rpx;
				position: absolute;
				top: 0;
				left: 0;
				z-index: -1;
			}

			.headtitile {
				width: 94%;
				margin: 0 auto;
				position: absolute;
				top: 94rpx;
				left: 3%;
				font-size: 30rpx;
				color: #FFFFFF;
			}

			.xinxi {
				width: 94%;
				margin: 0 auto;
				position: absolute;
				top: 183rpx;
				left: 3%;

				.shang {

					.logo {
						width: 184rpx;
						height: 184rpx;
						border-radius: 50%;
					}

					.right {
						margin-left: 28rpx;

						.username {
							font-size: 36rpx;
							color: #FFFFFF;
							font-weight: 700;
							margin-top: 46rpx;
							margin-bottom: 16rpx;
						}

						.name {
							font-size: 24rpx;
							color: #747474;
						}
					}
				}

				.xia {
					width: 100%;
					margin: 0 auto;
					margin-top: 14rpx;

					.li {
						width: 25%;
						text-align: center;

						.shuzi {
							font-size: 30rpx;
							color: #FFFFFF;
							font-weight: 700;
							margin-bottom: 8rpx;
						}

						.desc {
							font-size: 24rpx;
							color: #ABB0CC;
						}
					}
				}
			}
		}

		.mydownlast {
			width: 94%;
			margin: 0 auto;
			margin-bottom: 20rpx;
			background: #242831;
			border-radius: 10rpx;
			margin-top: 20rpx;

			.list {
				width: 94%;
				margin: 0 auto;
				height: 88rpx;
				line-height: 88rpx;
				box-sizing: border-box;

				.left {
					margin-right: 28rpx;
					height: 88rpx;
					line-height: 88rpx;

					image {
						width: 34rpx;
						height: 34rpx;
						margin-top: 28rpx;
					}
				}

				.center {
					font-size: 30rpx;
					color: #FFFFFF;
				}

				.right {
					margin-right: 10rpx;

					image {
						width: 16rpx;
						height: 28rpx;
						margin-top: 26rpx;
					}
				}
			}
		}

		.mydownlastxia {
			width: 94%;
			margin: 0 auto;
			margin-bottom: 20rpx;
			border-radius: 10rpx;
			background: #242831;

			.list {
				width: 94%;
				margin: 0 auto;
				height: 88rpx;
				line-height: 88rpx;
				box-sizing: border-box;
				border-bottom: 1rpx solid #31353E;

				.left {
					margin-right: 28rpx;
					height: 88rpx;
					line-height: 88rpx;

					image {
						width: 34rpx;
						height: 34rpx;
						margin-top: 28rpx;
					}
				}

				.center {
					font-size: 30rpx;
					color: #FFFFFF;
				}

				.right {
					margin-right: 10rpx;

					image {
						width: 16rpx;
						height: 28rpx;
						margin-top: 26rpx;
					}
				}
			}

			.list:last-child {
				border-bottom: none;
			}
		}

		.mydownlasttop {
			width: 100%;
			border-top-left-radius: 20rpx;
			border-top-right-radius: 20rpx;
			position: absolute;
			z-index: 300;
			background: #191D26;
			margin-top: -30rpx;
			padding-top: 20rpx;
		}
	}
</style>